
    # Log table Generator for Forbin LFO

maxv             = 2**32
num_out_steps    = 2**12
steps_per_octave = 400
max_osctaves     = 10
max_freq         = 100      # Hz

rxt = Array.new()

for idx in 0..num_out_steps

    stp = idx.to_f() * -0.0017328675
    fcv = 42949673.0 * Math.exp(stp)
    ifcv = (fcv + 0.5).to_i()
    
    rxt[idx] = fcv
    
    # work back to a frequency!
    
    afv = ( ifcv.to_f() / maxv.to_f() ) * 10000.0
    
    # printf("%6d %6d %9.3f\n", idx, ifcv, afv)

end

    # we intend to break the table into 128 entries

lrv = Array.new()
for idx in 0...128
    lrv.clear()
    sumx  = 0.0
    sumy  = 0.0
    sumxy = 0.0
    sumxx = 0.0
    sumyy = 0.0
    for nxx in 0...32
        spy   = rxt[idx * 32 + nxx].to_f()
        sumx  += nxx
        sumy  += spy
        sumxx += nxx * nxx
        sumyy += spy * spy
        sumxy += nxx * spy
        # printf("%4d %d %g %g %g %g %g\n", nxx, spy, sumx, sumy, sumxx, sumyy, sumxy)
    end
    sqx    = sumx * sumx
    sqy    = sumy * sumy
    slope  = ( (32.0 * sumxy) - (sumx * sumy) ) / (32.0 * sumxx - sqx)
    yint   = (sumy - (slope * sumx) ) / 32.0

    islope = (slope * -1.0 + 0.5).to_i()
    yfv    = (yint + 0.5).to_i()
    printf("     .long   %d,%d\n", islope, yfv)

    for nxx in 0...32
        ny = yint + nxx * slope
        iny = (ny + 0.5).to_i()
        iry = rxt[idx * 32 + nxx]
        dy  = iry - iny
        apy = dy / 42949673
        # printf("%d %d -> %d %g\n", iny, iry, dy, apy)
    end
    
end